﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Texfina.Entity.Rh;
using RHBOQry = Texfina.BOQry.Rh;
using Texfina.Core.Common;

namespace RH
{
   /// <summary>
   /// Summary description for MostrarImage
   /// </summary>
   public class MostrarImage : IHttpHandler
   {

      public void ProcessRequest(HttpContext context)
      {
         EPerFoto objEPerFoto = new EPerFoto();
         RHBOQry.Personal objBOPerFoto = (RHBOQry.Personal)WCFHelper.GetObject<RHBOQry.Personal>(typeof(RHBOQry.Personal));
         objEPerFoto.IdEmpresa = context.Request.QueryString["IdEmpresa"];
         objEPerFoto.IdPersonal = context.Request.QueryString["IdPersonal"];
         objEPerFoto = (EPerFoto)objBOPerFoto.GetByKeyPerFoto(objEPerFoto);

         if (objEPerFoto != null)
         {

            //MemoryStream ms = new MemoryStream(objEPerFoto.IdFotografia);
            //Bitmap bm = null;
            //bm = new Bitmap(ms);
            ////this.imgidFotografia.ImageUrl = bm;  
            context.Response.ContentType = "image/jpeg";
            context.Response.Expires = 0;
            context.Response.Buffer = true;
            context.Response.Clear();
            context.Response.BinaryWrite(objEPerFoto.IdFotografia);
            context.Response.End();

         }


      }

      public bool IsReusable
      {
         get
         {
            return false;
         }
      }
   }
}